<template>
	<div style="display: inline-block;">
		<div @click.stop="doDelete(item)">
			<div class="aui-btn aui-btn-outlined m-delete"><i class="aui-iconfont aui-icon-trash"></i>删除</div>
		</div>
	</div>
</template>

<script>
	import {MessageBox} from '../../../ui-components';
	import {mapActions,mapGetters,mapMutations} from 'vuex';
	export default {
		props:{
			item: {
                type: Object,
                default:()=>{
                	return {}
                }
            },
            userInfomation: {
            	type: Object,
                default: ()=>{
                	return {}
                }
            },
            getstatusBtn: {
            	type: Function,
                default: () => {}
            }
		},
		data() {
			return {
				
			}
		},
		created(){
//			console.log(this.item,this.userInfomation,this.getstatusBtn,'9')
		},
		computed: {
			...mapGetters('qxz',[
				"getLocation"
			]),
		},
		methods: {
			...mapActions('zx',[
				'setAddressInfo'
			]),
			...mapMutations('zx',[
				"setHomeAddressNow"
			]),
			doDelete(item) {
				if(item && this.getLocation){
					if(item.addressid == this.getLocation.addressid){
						console.log('设置首页dizhi')
						this.$store.dispatch('qxz/updateLocation', null);  // 用户将首页选择的地址删了，做同步操作
						localStorage.setItem('locateIn',null);
						localStorage.setItem('chooseAddressActiveIndex',null);
					}
				}
				
	            let params = {
					type : "DEL",
					addressid:item.addressid
				}
	            MessageBox.confirm('是否删除地址？').then((action)=>{
	            	params.addressid = item.addressid;
	          	    this.setAddressInfo(params);
	            })

	       }
		}
	}
</script>

<style>
</style>